-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid duplicate file level functions and variables in namespace rewrite #918
Conversation
@Amxx I changed this to keep dummy variables for We now also replace Can you please review the overall changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just minor question
Summary: Changed to not delete any nodes and not delete documentation. Instead, replaces functions and other unneeded nodes with dummy enums, either with the original name (if the identifier could be imported in other files) or with a random identifier based on the AST node ID (if the identifier is no longer relevant or if it was originally an overloaded function). This avoids any possibility of NatSpec getting orphaned or mixed up with different nodes than originally written, which could lead to compile errors. Enums are able to compile with any NatSpec tag even if they are not relevant. |
To extract storage layouts for namespaces, the Hardhat plugin makes a copy of the user's source code and makes modifications to this copy: it injects storage variables for namespaced structs and removes everything that is not needed (to speed up compilation).
File level functions and variables are not removed, but are replaced with dummy constants in case they are imported by another file. However, overloaded functions would cause duplicate identifiers to exist, which causes compilation to fail when compiling this modified copy of source code.
We should keep track of identifiers to avoid duplicates in this case.
Fixes #917